package com.abl.common.mybatis.strengthen;

import com.abl.common.util.AuthKit;
import com.abl.common.util.DateKit;
import com.abl.common.util.IdKit;

import java.util.Arrays;
import java.util.List;

public enum FillColumn {
    id("id", IdKit.getId(), "数据主键ID"),

    d_ci("d_ci", AuthKit.getLoginUserId(), "创建人ID"),
    d_ui("d_ui", AuthKit.getLoginUserId(), "修改人ID"),

    d_ca("d_ca", "0", "创建人账号"),
    d_ua("d_ua", "0", "修改人账号"),

    d_cn("d_cn", AuthKit.getLoginName(), "创建人昵称"),
    d_un("d_un", AuthKit.getLoginName(), "修改人昵称"),

    d_ct("d_ct", DateKit.nowDate(), "创建时间"),
    d_ut("d_ut", DateKit.nowDate(), "修改时间"),

    d_v("d_v", "0", "版本号"),
    d_s("d_s", "0", "数据状态"),

    insert(Arrays.asList("id", "d_ct", "d_ut", "d_ci", "d_ui", "d_cn", "d_un"), "默认Insert填充"),
    update(Arrays.asList("d_ut", "d_un"), "默认Update填充"),
    delete(Arrays.asList("d_ut", "d_un"), "默认Delete填充");

    private String key = null;
    private Object defaultValue = null;
    private List<String> keys;
    private final String desc;

    FillColumn(String key, Object defaultValue, String desc) {
        this.key = key;
        this.defaultValue = defaultValue;
        this.desc = desc;
    }

    FillColumn(List<String> keys, String desc) {
        this.keys = keys;
        this.desc = desc;
    }

    public Object defaultValue() {
        return defaultValue;
    }

    public String key() {
        return key;
    }

    public List<String> keys() {
        return keys;
    }

    public String toString() {
        return "{" +
                "  \"code\": " + key +
                "  \"message\": " + desc +
                "}";
    }
}
